<?php
/**
 * Created by PhpStorm.
 * User: weijer
 * Date: 2018/10/26
 * Time: 21:17
 */

namespace common\validate;

use think\Validate;

class Capacity extends BaseValidate
{
    //验证规则
    protected $rule = [];

    // Fields 验证场景定义
    public function sceneFields()
    {
        return $this;
    }

    // Find 验证场景定义
    public function sceneFind()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array');
    }

    // Select 验证场景定义
    public function sceneSelect()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array')
            ->append('param.page', 'array');
    }

    // Create 验证场景定义
    public function sceneCreate()
    {
        return $this->append('data.name', 'require|max:128')
            ->append('data.code', 'max:128');
    }

    // Update 验证场景定义
    public function sceneUpdate()
    {
        return $this->append('data.id', 'require')
            ->append('data.name', 'max:128')
            ->append('data.code', 'max:128');
    }

    // Delete 验证场景定义
    public function sceneDelete()
    {
        return $this->append('param.filter', 'require|array');
    }

    // WriteTenantDingTalkConfig 验证场景定义
    public function sceneWriteTenantDingTalkConfig()
    {
        return $this->append('data', 'require')
            ->append('data.tenant_id', 'require')
            ->append('data.corp_id', 'require')
            ->append('data.app_key', 'require')
            ->append('data.app_secret', 'require')
            ->append('data.working_hours', 'require');
    }

    // ReviseTenantSchedulingRecord 验证场景定义
    public function sceneReviseTenantSchedulingRecord()
    {
        return $this->append('tenant_id', 'require');
    }


    public function sceneSaveCapacityConfig()
    {
        return $this->append('data.team_category_id', 'require|integer')
            ->append('data.name', 'require')
            ->append('data.type', 'require')
            ->append('data.default_capacity_num', 'integer|between:0,100000');
    }

    public function sceneDelCapacityConfig()
    {
        return $this->append('param.filter.ids', 'require');
    }

    public function sceneSaveTenantCapacity()
    {
        return $this->append('data.id', 'require|integer')
            ->append('data.tenant_id', 'require|integer')
            ->append('data.default_capacity_num', 'integer|between:0,100000');
    }

    public function sceneGetCapacityReportList()
    {
        return $this->append('param.team_category_id', 'require')
            ->append('param.end_time', 'require|integer')
            ->append('param.start_time', 'require|integer');
    }

}
